﻿using ShaderCompiler.Core;

namespace ShadersCS
{
	public sealed class Simulate : BaseVS
	{
		[ArrayType(8)]
		public Vector2[] sampleOffsets;
		public Texture2D MyTexture;

		[ShaderMethod(ShaderMethodTypes.PS)]
		public void mainPS()
		{
			Vector4 color = MyTexture.Sample(Texcoord_VSPS);
			color = (color-0.5) * 2.0;

			double force = -color.z;
			for (int i = 0; i != 8; ++i)
			{
				Vector4 block = MyTexture.Sample(Texcoord_VSPS + (sampleOffsets[i] * simulateSize));
				block = (block-0.5) * 2.0;

				force += (block.z - color.z);
			}
			color.x += force * 0.11111111111111111111111111111111;
			color.x *= .99;
			color.z += color.x;

			Color_PS = (color+1.0) * 0.5;
		}
	}
}
